Ex011, Picture in record


This example illustrates the use of Image fields.

Exercise 011: Picture in record:

1. Design below table using Database Desktop.

----------------------------------
Field Name  | Type  | Size | Key |
---------------------------------|
PID         |   +   |      |  *  |
Name      
|   A   |  30  |     |
DOB         |   D   |      |     |
Photo       |   G   |      |     |
----------------------------------

2. Save the table as
'Person' in DBDEMOS Alias.
3. Drop a
Table. Select DBDEMOS at DataBase property. Select 'Person' at TableName property.
4. Drop a DataSource. Select Table1 at DataSet property.
5. Drop three
DBEdit boxes. Select DataSource1 at DataSource property for all DBEdit
boxes. On
DataField property select PID for the first DBEdit box, Name for second,
and
DOB for last one.
6. Drop three
Labels for DBEdit boxes and caption it according to it's fields.
7. Drop a
DBNavigator. Select DataSource1 at DataSource property.
8. Drop an
OpenPictureDialog.
9. Drop a DBImage from
Data Controls page. Select DataSource1 at DataSource property.
Select
Photo at DataField property.
10. At DBImage1's
OnDblClick event write:

 with OpenPictureDialog1 do
if Execute then
begin
  Table1.Edit;
  DBImage1.Picture.LoadFromFile(FileName);
  Table1.Post;
end;

11. At Form1's
OnClick event write:

 Table1.Open;

12. Run the program then click (+) field to add new record, write name and date
of birth, then double click on image then select bitmap photo for current person.